﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class NewUser : System.Web.UI.Page
{
    MyDataDataContext db = new MyDataDataContext();
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void BtnNewUser_Click(object sender, EventArgs e)
    {
        //basic(sender, e);
        User user= (from c in db.User
                    where c.UserNickname == txtName.Text && c.UserPhone== txtNum.Text
                    select c).FirstOrDefault();
        if(user!=null)
        {
            lblMsg.Text = "用户名已存在！";
        }
        User customer = new User
        {
            UserID = "00",
            UserNickname = txtName.Text,
            UserPwd = txtPwd.Text,
            UserPhone = txtNum.Text,
            UserAddress = txtAddress.Text,
            QQ = txtQQ.Text,
            UserSex=man.Text,
            StudentNumber=stuNum.Text
        };
        db.User.InsertOnSubmit(customer);
        db.SubmitChanges();
        Response.Redirect("Login.aspx?name=" + txtName);

    }
    
    }